#!/bin/bash

# 关闭防火墙
systemctl stop firewalld
setenforce 0

# vmx-intel ;svm-amd
grep -E "(vmx|svm)" /proc/cpuinfo

# 安装软件包
yum -y install kvm qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools bridge-utils virt-install

#
yum install libvirtd
#
systemctl start libvirtd

# 配置虚拟网卡
cd /etc/sysconfig/network-scripts
cp ifcfg-ens33 ifcfg-br0


systemctl restart network

# 查看kvm模块是否加载
lsmod |grep kvm

#安装虚拟机
virt-install --name=study01 --memory=1024,maxmemory=1024 --vcpus=1,maxvcpus=2 --os-type=linux --os-variant=rhel7 \
--location=/root/CentOS-7-x86_64-Minimal-1908.iso --disk path=/kvm/study01.img,size=10 \
--bridge=br0 --graphics=none --console=pty,target_type=serial  --extra-args="console=tty0 console=ttyS0"
